<template>
    <div id="wai">
        <div class="nei">
            <h1 class="title">{{ msg }}</h1>
            <div class="news">
                <p>名称：{{ goods_news['name'] }}</p>
                <p>单价：{{ goods_news['order_price'] }}￥</p>
                <p>数量：{{ goods_news['count'] }}件</p>
                <p>收货地址：{{ goods_news['province'] }}-{{ goods_news['detailed_address'] }}</p>
                <p>联系电话：{{ goods_news['phone_number'] }}</p>
                <p>创建时间：{{ goods_news['create_time'] }}</p>
                <p>总价：{{ goods_news['order_price'] * goods_news['count'] }}￥</p>
                <button @click="go_pay" class="pay">确认支付</button>
            </div>
        </div>
    </div>
</template>
  
<script>

export default {
    props: ['id'],
    data() {
        return {
            msg: '支付页面',
            orders: {
                order_id: this.id,
                session_id: this.$auth.getAuthorization()
            },
            goods_news: {}
        }
    },
    created() {
        this.get_orders_news();
    },
    mounted() { },
    methods: {
        //获取创建的订单的信息
        get_orders_news() {
            this.$http.post('get_order_news.php', this.orders,
                {
                    headers: {
                        'Content-Type': 'application/json' // 设置请求头
                    }
                }).then(response => {
                    if (response.data.status === 1) {
                        // alert(response.data.message);
                        this.goods_news = response.data.data;
                        console.log(response.data.message);
                    } else {
                        alert(response.data.message);
                        // console.log(response.data.message);
                    }
                })
                .catch(error => {
                    console.error(error);
                });
        },
        go_pay() {
            this.$http.post('go_pay.php', this.orders,
                {
                    headers: {
                        'Content-Type': 'application/json' // 设置请求头
                    }
                }).then(response => {
                    if (response.data.status === 1) {
                        alert(response.data.message);
                        // this.$router.push('/shopping');
                        this.$router.go(-1);
                        // this.goods_news = response.data.data;
                        // console.log(response.data.message);
                    } else {
                        alert(response.data.message);
                        // console.log(response.data.message);
                    }
                })
                .catch(error => {
                    console.error(error);
                });
        },
    }
}
</script>
  
  
  
<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
}

#wai {
    .nei {
        .title {
            font-size: 50px;
            margin-top: 2%;
        }

        .news {
            padding-left: 25%;
            padding-top: 5%;

            p {
                font-size: 30px;
                margin-top: 3%;
                color: black;
            }

            .pay {
                width: 150px;
                height: 50px;
                margin-top: 3%;
            }
        }

    }

}
</style>